<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-18 22:33:04
 * @LastEditTime: 2023-08-03 15:35:43
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: 
 */

namespace App\Models;
use App\Traits\CommonUserTrait;

class Loom extends BaseModel
    {
    use CommonUserTrait;
    public $timestamps = true;
    //
    public $table = "basedata_loom";
    protected $guarded = [];
    // 
    protected $casts = [
        'dosage' => 'int',
    ];
    public function status()
        {
        return $this->belongsTo(Dic::class, "status_id", "key")->where(function ($q)
            {
            $q->where("code", 'table_status');
            });
        }
    public function category()
        {
        return $this->belongsTo(Dic::class, "category_id", "key")->where(function ($q)
            {
            $q->where("code", 'MachineCategory');
            });
        }
    public function color()
        {
        return $this->belongsTo(ProColor::class);
        }
    public function process()
        {
        return $this->belongsTo(ProProcesses::class);
        }
    public function details()
        {
        return $this->hasMany(LoomDetails::class, "main_id");
        }
    public function ratios()
        {
        return $this->hasMany(LoomRatio::class, "loom_id");
        }
    public function open_card()
        {
        return $this->hasMany(OpenCardDetails::class, "machine_id");
        }
    public function open_card_details_scheduling()
        {
        return $this->hasMany(OpenCardDetailsScheduling::class, "machine_id");
        }
    }